package com.dingup.provider.feign.server.sys;

import com.dingup.api.model.sys.SysDept;
import com.dingup.api.model.sys.SysUser;
import com.dingup.provider.mapper.SysDeptMapper;
import com.dingup.provider.service.sys.SysDeptService;
import com.dingup.provider.service.sys.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by wancheng on 2018/7/30.
 */
@RestController()
@RequestMapping("/sysDept")
public class DeptFeign {

    @Autowired
    SysDeptService sysDeptService;

    @Autowired
    SysDeptMapper sysDeptMapper;

    @Autowired
    SysUserService sysUserService;

    @RequestMapping(value = "/get_tree_dept_by_deptId",method = RequestMethod.POST)
    public List<SysDept> getByUnionId(Long rootId) {
        List<SysDept> depts = sysDeptService.get(rootId);
        return depts;
    }

    @RequestMapping(value = "/get_dept_by_useId",method = RequestMethod.POST)
    public List<SysDept> getDeptByUserId(String userId) {
        List<SysDept> depts = sysDeptMapper.getDeptByUserId(userId);
        return depts;
    }
    @RequestMapping(value = "/get_user_by_deptIds",method = RequestMethod.POST)
    public List<SysUser> getDeptByUserIds(List<Long> deptIds) {
        List<SysUser> users = sysUserService.getUserByDeptIds(deptIds);
        return users;
    }
}
